const cheerio = require('cheerio')
const urlJoin = require('url-join')
const Setting = require('../setting')

function getList(pList) {
	const $ = cheerio.load(pList)
	const urlList = []
	const list = $('.for-list li').each((index, el) => {
		urlList.push({
			title: $(el).find('.truetit').text(),
			author: $(el).find('.aulink').text(),
			url: urlJoin(Setting.hupu.base_url,$(el).find('.truetit').attr('href'))
		})
	})
	return urlList
}
function getImgList(d) {
	const $ = cheerio.load(d)
	const list = $('img')
	list.each((index, el) => {
		console.log($(el).attr('src'))
	})

	// console.log($('img').html())
}

module.exports = {
	getList,
	getImgList
}
